package org.wu.framework.authorization.platform.application.impl;

import jakarta.annotation.Resource;
import org.wu.framework.authorization.platform.application.SysZoneApplicationVersionApplication;
import org.wu.framework.authorization.platform.application.assembler.SysZoneApplicationVersionDTOAssembler;
import org.wu.framework.authorization.platform.application.command.sys.zone.application.version.*;
import org.wu.framework.authorization.platform.application.dto.SysZoneApplicationVersionDTO;
import org.wu.framework.authorization.platform.domain.model.sys.zone.application.version.SysZoneApplicationVersion;
import org.wu.framework.authorization.platform.domain.model.sys.zone.application.version.SysZoneApplicationVersionRepository;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;

import java.util.List;
import java.util.stream.Collectors;
/**
 * describe 应用版本 
 *
 * @author Jia wei Wu
 * @date 2024/04/02 06:21 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl 
 **/
@LazyApplication
public class SysZoneApplicationVersionApplicationImpl implements SysZoneApplicationVersionApplication {

    @Resource
    SysZoneApplicationVersionRepository sysZoneApplicationVersionRepository;
    /**
     * describe 新增应用版本
     *
     * @param sysZoneApplicationVersionStoryCommand 新增应用版本
     * @return {@link Result< SysZoneApplicationVersion >} 应用版本新增后领域对象
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<SysZoneApplicationVersion> story(SysZoneApplicationVersionStoryCommand sysZoneApplicationVersionStoryCommand) {
        SysZoneApplicationVersion sysZoneApplicationVersion = SysZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(sysZoneApplicationVersionStoryCommand);
        return sysZoneApplicationVersionRepository.story(sysZoneApplicationVersion);
    }
    /**
     * describe 批量新增应用版本
     *
     * @param sysZoneApplicationVersionStoryCommandList 批量新增应用版本
     * @return {@link Result<List< SysZoneApplicationVersion >>} 应用版本新增后领域对象集合
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<SysZoneApplicationVersion>> batchStory(List<SysZoneApplicationVersionStoryCommand> sysZoneApplicationVersionStoryCommandList) {
        List<SysZoneApplicationVersion> sysZoneApplicationVersionList = sysZoneApplicationVersionStoryCommandList.stream().map( SysZoneApplicationVersionDTOAssembler.INSTANCE::toLazyZoneApplicationVersion).collect(Collectors.toList());
        return sysZoneApplicationVersionRepository.batchStory(sysZoneApplicationVersionList);
    }
    /**
     * describe 更新应用版本
     *
     * @param sysZoneApplicationVersionUpdateCommand 更新应用版本
     * @return {@link Result< SysZoneApplicationVersion >} 应用版本领域对象
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<SysZoneApplicationVersion> updateOne(SysZoneApplicationVersionUpdateCommand sysZoneApplicationVersionUpdateCommand) {
        SysZoneApplicationVersion sysZoneApplicationVersion = SysZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(sysZoneApplicationVersionUpdateCommand);
        return sysZoneApplicationVersionRepository.story(sysZoneApplicationVersion);
    }

    /**
     * describe 查询单个应用版本
     *
     * @param sysZoneApplicationVersionQueryOneCommand 查询单个应用版本
     * @return {@link Result< SysZoneApplicationVersionDTO >} 应用版本DTO对象
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<SysZoneApplicationVersionDTO> findOne(SysZoneApplicationVersionQueryOneCommand sysZoneApplicationVersionQueryOneCommand) {
        SysZoneApplicationVersion sysZoneApplicationVersion = SysZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(sysZoneApplicationVersionQueryOneCommand);
        return sysZoneApplicationVersionRepository.findOne(sysZoneApplicationVersion).convert(SysZoneApplicationVersionDTOAssembler.INSTANCE::fromLazyZoneApplicationVersion);
    }

    /**
     * describe 查询多个应用版本
     *
     * @param sysZoneApplicationVersionQueryListCommand 查询多个应用版本
     * @return {@link Result<List< SysZoneApplicationVersionDTO >>} 应用版本DTO对象
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<SysZoneApplicationVersionDTO>> findList(SysZoneApplicationVersionQueryListCommand sysZoneApplicationVersionQueryListCommand) {
        SysZoneApplicationVersion sysZoneApplicationVersion = SysZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(sysZoneApplicationVersionQueryListCommand);
        return sysZoneApplicationVersionRepository.findList(sysZoneApplicationVersion)        .convert(lazyZoneApplicationVersions -> lazyZoneApplicationVersions.stream().map(SysZoneApplicationVersionDTOAssembler.INSTANCE::fromLazyZoneApplicationVersion).collect(Collectors.toList())) ;
    }

    /**
     * describe 分页查询多个应用版本
     *
     * @param sysZoneApplicationVersionQueryListCommand 分页查询多个应用版本
     * @return {@link Result<LazyPage< SysZoneApplicationVersionDTO >>} 分页应用版本DTO对象
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyPage<SysZoneApplicationVersionDTO>> findPage(int size, int current, SysZoneApplicationVersionQueryListCommand sysZoneApplicationVersionQueryListCommand) {
        SysZoneApplicationVersion sysZoneApplicationVersion = SysZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(sysZoneApplicationVersionQueryListCommand);
        return sysZoneApplicationVersionRepository.findPage(size,current, sysZoneApplicationVersion)        .convert(page -> page.convert(SysZoneApplicationVersionDTOAssembler.INSTANCE::fromLazyZoneApplicationVersion))            ;
    }

    /**
     * describe 删除应用版本
     *
     * @param sysZoneApplicationVersionRemoveCommand 删除应用版本
     * @return {@link Result< SysZoneApplicationVersion >} 应用版本
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<SysZoneApplicationVersion> remove(SysZoneApplicationVersionRemoveCommand sysZoneApplicationVersionRemoveCommand) {
     SysZoneApplicationVersion sysZoneApplicationVersion = SysZoneApplicationVersionDTOAssembler.INSTANCE.toLazyZoneApplicationVersion(sysZoneApplicationVersionRemoveCommand);
     return sysZoneApplicationVersionRepository.remove(sysZoneApplicationVersion);
    }

}